<?php
    include_once("Configs/database.php");
    include_once("NguoiDung.php");
    class SinhVien extends NguoiDung{
        private $hoten;
        
        private $ngaysinh;
        private $phai;
        
        private $email;
        private $sodt;
        
        public function sethoten($hoten){
            $this->hoten = $hoten;
        }
        public function gethoten(){
            return $this->hoten;
        }
        
        
        public function setNgaySinh($ngaysinh){
            $this->ngaysinh = $ngaysinh;
        }
        public function getNgaySinh(){
            return $this->ngaysinh;
        }
        public function setPhai($phai){
            $this->phai = $phai;
        }
        public function getPhai(){
            return $this->phai;
        }
        
        
        
        public function setEmail($email){
            $this->email = $email;
        }
        public function getEmail(){
            return $this->email;
        }
        
        public function setSoDT($sodt){
            $this->sodt = $sodt;
        }
        public function getSoDT(){
            return $this->sodt;
        }
        
        public function themSinhVien(){
            $query = "insert into SinhVien(maso,hoten,ngaysinh,phai,email,sodt) values ('".$this->getMaSo()."','".$this->gethoten()."', ";
            $query .= "str_to_date('".$this->getNgaySinh()."', '%d-%m-%Y'),".$this->getPhai().",'".$this->getEmail()."','".$this->getSoDT()."')";
            $this->setQuery($query);
            //echo $this->getQuery();
            return $this->executeQuery();
        }
        public function suaSinhVien(){
            $query = "update sinhVien set hoten='".$this->gethoten()."',phai=".$this->getPhai().", ";
            $query .= "email='".$this->getEmail()."',sodt='".$this->getSoDT()."' where maso='".$this->getMaSo()."'";
             //echo $this->getQuery();
            $this->setQuery($query);
            return $this->executeQuery();
        }
        public function xoaSinhVien(){
            $this->setQuery("delete SinhVien where  maso='".$this->getMaSo()."'");
            return $this->executeQuery();
        }
        public function thongtinSinhVien(){
            //$query = "select maso, hoten, date_format(ngaysinh,'%d-%m-%Y') as ngaysinh, (case phai when 0 then N'N?' when 1 then 'Nam' end) as phai, email, sodt from SinhVien";
			$query = "select maso, hoten,date_format(ngaysinh,'%d-%m-%Y') as ngaysinh, phai, email, sodt from SinhVien";
            $query .= " where  maso='".$this->getMaSo()."'";
            $this->setQuery($query);
            return $this->fetchAll();
        }
        
    }
?>